package net.optix.ip.business
{
	import com.adobe.cairngorm.business.Responder;
	
	import mx.rpc.http.HTTPService;
	
	import net.optix.ip.model.ModelLocator;
	import net.optix.ip.vo.ActionVO;
	import net.optix.ip.vo.TradeMarkVO;
	
	public class TradeMarkDelegate
	{
		private var responder:Responder;
		private var service:HTTPService;
		
		public function	listener():void
		{
			service.method = "POST";
            service.resultFormat	=	HTTPService.RESULT_FORMAT_E4X;
            service.addEventListener("result", responder.onResult);
            service.addEventListener("fault", responder.onFault);
		}
		
		public function recordTradeMark(responder:Responder,vo:TradeMarkVO):void
		{
			this.responder	=	responder;
			service 		= 	new HTTPService();
			service.url		=	ModelLocator.getInstance().url+"/TradeMark/RecordTradeMark";
            this.listener();
            //service.resultFormat	=	HTTPService.RESULT_FORMAT_TEXT;
            service.send({
            	ClientID:vo.clientID,
				TradeMark:vo.tradeMark,
				Excluded:vo.excluded,
				FirstUseDate:vo.firstUseDate,
				Filed:vo.filed,
				SerialNumber:vo.serialNumber,
				Registered:vo.registered,
				RegistrationNumber:vo.registrationNumber,
				RegistrationDate:vo.registrationDate,
				RenewBy:vo.renewBy
            	});
		}
		
		public function assignTradeMarkToFirm(responder:Responder,vo:TradeMarkVO):void
		{
			this.responder	=	responder;
			service 		= 	new HTTPService();
			service.url		=	ModelLocator.getInstance().url+"/TradeMark/AssignTradeMarkToFirm";
            this.listener();
            //service.resultFormat	=	HTTPService.RESULT_FORMAT_TEXT;
            service.send({
            	TradeMarkID:vo.tradeMarkID,
            	MaxBudget:vo.maxBudget,
            	DeadlineDate:vo.deadlineDate,
            	FirmID:vo.firmID
            });
		}
		
		public function acceptAssignMark(responder:Responder,vo:TradeMarkVO):void
		{
			this.responder	=	responder;
			service 		= 	new HTTPService();
			service.url		=	ModelLocator.getInstance().url+"/TradeMark/AcceptAssignMark";
            this.listener();
            //service.resultFormat	=	HTTPService.RESULT_FORMAT_TEXT;
            service.send({
            	TradeMarkID:vo.tradeMarkID,
            	BConfirm:vo.bConfirm,
            	FirmID:vo.firmID,
            	ClientID:vo.clientID
            });
		}
		
		public function getTradeMarks(responder:Responder,userID:int,role:int):void
		{
			this.responder	=	responder;
			service 		= 	new HTTPService();
			service.url		=	ModelLocator.getInstance().url+"/TradeMark/GetTradeMarks";
            this.listener();
            //service.resultFormat	=	HTTPService.RESULT_FORMAT_TEXT;
            service.send({
            	UserID:userID,
            	Role:role
            	});
		}
		
		public function getBidTradeMarks(responder:Responder,firmID:int):void
		{
			this.responder	=	responder;
			service 		= 	new HTTPService();
			service.url		=	ModelLocator.getInstance().url+"/TradeMark/GetBidTradeMarks";
            this.listener();
            //service.resultFormat	=	HTTPService.RESULT_FORMAT_TEXT;
            service.send({
            	FirmID:firmID
            	});
		}
		
		public function getTradeMark(responder:Responder,tradeMarkID:int,userID:int,role:int):void
		{
			this.responder	=	responder;
			service 		= 	new HTTPService();
			service.url		=	ModelLocator.getInstance().url+"/TradeMark/GetTradeMark";
            this.listener();
            //service.resultFormat	=	HTTPService.RESULT_FORMAT_TEXT;
            service.send({
            	TradeMarkID:tradeMarkID,
            	UserID:userID,
            	Role:role
            	});
		}
		
		public function getTradeMarkActions(responder:Responder,tradeMarkID:int):void
		{
			this.responder	=	responder;
			service 		= 	new HTTPService();
			service.url		=	ModelLocator.getInstance().url+"/TradeMark/GetTradeMarkActions";
            this.listener();
            //service.resultFormat	=	HTTPService.RESULT_FORMAT_TEXT;
            service.send({
            	TradeMarkID:tradeMarkID
            	});
		}
		
		public function addAction(responder:Responder,vo:ActionVO):void
		{
			this.responder	=	responder;
			service 		= 	new HTTPService();
			service.url		=	ModelLocator.getInstance().url+"/TradeMark/AddAction";
            this.listener();
            //service.resultFormat	=	HTTPService.RESULT_FORMAT_TEXT;
            service.send({
				TradeMarkID:vo.inventionID,
				Title:vo.title,
				Type:vo.type,
				Description:vo.description,
				FileNames:vo.fileNames,
				Cost:vo.cost
			});
		}
	}
}